home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 43
/
Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso
/
-serious-
/
wb
/
backclock
/
sources
/
timer.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-06-15
|
2KB
|
57 lines
/*****************************************************************************
*
* Nom: timer.c
* Desc: handle timer
*
*
* version : $VER: timer.c 1.11 (05.06.99)
*
*****************************************************************************
*/
#include <proto/exec.h>
#include <devices/timer.h>
#include <exec/io.h>
#include "utils.h"
#include "timer.h"
#include <clib/rtracker_protos.h>
#include <pragmas/rtracker_pragmas.h>
extern struct Library * RTrackerLibrary ;
int initTimer(idWin * prj) {
// retourne TRUE si initialisation ok
int ret = FALSE ;
prj->timerok = FALSE ; // ok (pour le refermer)
if ((prj->trport = NewCreateMsgPort()) != NULL) {
// creation port message ok
if ((prj->treq = (struct timerequest *)NewCreateIORequest(prj->trport, sizeof(struct timerequest))) != NULL) {
// creation ioreq ok
if (!OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest*)prj->treq, 0)) {
// ouverture timer ok
ret = TRUE ;
prj->timerok = TRUE ;
}
}
}
return ret ;
}
void closeTimer(idWin * prj) {
if (prj->timerok)
CloseDevice((struct IORequest*)prj->treq) ;
if (prj->treq)
NewDeleteIORequest((struct IORequest*)prj->treq) ;
if (prj->trport)
NewDeleteMsgPort(prj->trport) ;
}
void runtimer(idWin * prj, long seconds) {
/* lance le timer
*/
if (prj->timerok) {
prj->treq->tr_time.tv_secs = seconds ;
prj->treq->tr_time.tv_micro = NULL ;
prj->treq->tr_node.io_Command = TR_ADDREQUEST ;
SendIO((struct IORequest *)prj->treq) ;
}
}